<template>
  <div class="muisc-list">    
    <div class="skeleton">
      <li v-for="item in 3">
        <van-skeleton avatar avatar-shape="avatar-shape" avatar-size="100" :loading="skeLoading" />
        <van-skeleton style="margin-top:10px" :row="2" :loading="skeLoading" />
      </li>
    </div>
    
    <div class="music-item" v-for="item in hotMusic">
      <router-link :to="{
        path: '/music/musicListDetail',
        query: { id: item.id }
      }">
        <div class="item-box">
          <van-image :src="item.picUrl" />
          <div class="title van-multi-ellipsis--l2">
            {{ item.name }}
          </div>
        </div>
      </router-link>
    </div>
  </div>

</template>

<script setup>
import { reactive, toRefs, ref, onMounted } from 'vue'
import { playlistHot, resourceDay } from '@/request/api/musicApi'
import { useRouter } from 'vue-router'
const $router = useRouter();
let showLoadingIcon = ref(true)
let hotMusic = ref([]);
let skeLoading = ref(true);

onMounted(() => {
  initData();
});

const initData = () => {
  getResourceDay();
}

const getResourceDay = async () => {
  await resourceDay().then(data => {
    hotMusic.value = data.recommend
    skeLoading.value = false
  })
}
</script>
  
<style lang='less' scoped>
.skeleton{
  display: flex;
  flex-wrap: nowrap;
  li{
    width: 33%;
  }
}
.van-loading {
  text-align: center;
}

.scroll-x {
  white-space: nowrap;
  overflow-x: scroll;

  div {
    width: 400px;
    display: inline-block;
  }
}

.muisc-list {
  margin-top: 20px;

  overflow-x: scroll;
  white-space: nowrap;

  // 隐藏滚动条
  &::-webkit-scrollbar {
    width: 0px;
  }

  .music-item {
    display: inline-block;
    overflow: auto;
    width: 270px;
    margin-left: 20px;

    .item-box {
      // display: flex;
      // flex-wrap: wrap;
      display: grid;
      white-space: normal;
    }

    .van-image {
      max-width: 100%;
      border-radius: 25px;
      overflow: hidden;
    }

    .title {
      font-size: 28px;
      min-height: 2em;
    }

  }
}
</style>